/**
 * 商城-商品
 */
import {
  request,
  requestSync
} from '@/utils/request'

// 商品列表
export const listProduct = (data) => {
  return requestSync({
    url: '/system/mall/product/listProduct',
    method: 'post',
    data,
  })
}

// 添加商品
export const addProduct = (data) => {
  return requestSync({
    url: '/system/mall/product/addProduct',
    method: 'post',
    data,
  })
}

// 修改商品
export const updateProduct = (data) => {
  return requestSync({
    url: '/system/mall/product/updateProduct',
    method: 'post',
    data,
  })
}

// 获取商品详情
export const getProductInfo = (productId) => {
  return requestSync({
    url: '/system/mall/product/getProductInfo',
    method: 'post',
    data: {
      productId
    }
  })
}

// 上架商品
export const onlineProduct = (productId) => {
  return requestSync({
    url: '/system/mall/product/onlineProduct',
    method: 'post',
    data: {
      productId
    }
  })
}

// 下架商品
export const offlineProduct = (productId) => {
  return requestSync({
    url: '/system/mall/product/offlineProduct',
    method: 'post',
    data: {
      productId
    }
  })
}

// 删除商品
export const deleteProduct = (productId) => {
  return requestSync({
    url: '/system/mall/product/deleteProduct',
    method: 'post',
    data: {
      productId
    }
  })
}

// 预约管理列表
export const productAppointmentList = (data) => {
  return requestSync({
    url: '/system/product/appointment/list',
    method: 'post',
    data
  })
}

// 分配
export const productAppointmentAllot = data => {
  return requestSync({
    url: '/system/product/appointment/allot',
    method: 'post',
    data
  })
}
// 商城设置
export const mallSettingUpdate = data => {
  return requestSync({
    url: '/system/mallSetting/update',
    method: 'post',
    data
  })
}

// 商城设置-详情
export const mallSettingInfo = () => {
  return requestSync({
    url: '/system/mallSetting/info',
    method: 'post',
  })
}

// 商城订单管理 - 列表
export const mallOrderList = data => {
  return requestSync({
    url: '/system/mallOrder/list',
    method: 'post',
    data
  })
}

// 商城订单管理 - 详情
export const mallOrderInfo = (orderId) => {
  return requestSync({
    url: '/system/mallOrder/info',
    method: 'post',
    data: {
      orderId
    }
  })
}

// 商城订单管理 - 退款
export const refundOk = (orderId) => {
  return requestSync({
    url: '/system/mallOrder/refundOk',
    method: 'post',
    data: {
      orderId
    }
  })
}


// // 优惠券 - 添加
// export const addCoupon = data => {
//   return requestSync({
//     url: '/system/mallCoupon/addCoupon',
//     method: 'post',
//     data
//   })
// }

// // 优惠券 - 列表
// export const listCoupon = data => {
//   return requestSync({
//     url: '/system/mallCoupon/listCoupon',
//     method: 'post',
//     data
//   })
// }

// // 优惠券 - 详情
// export const infoCoupon = (couponId) => {
//   return requestSync({
//     url: '/system/mallCoupon/getCouponInfo',
//     method: 'post',
//     data: {
//       couponId
//     }
//   })
// }

// // 优惠券 - 删除
// export const deleteCoupon = (couponId) => {
//   return requestSync({
//     url: '/system/mallCoupon/deleteCoupon',
//     method: 'post',
//     data: {
//       couponId
//     }
//   })
// }


// // 优惠券 - 状态 - 开启
// export const openCoupon = (couponId) => {
//   return requestSync({
//     url: '/system/mallCoupon/onCouponState',
//     method: 'post',
//     data: {
//       couponId
//     }
//   })
// }

// // 优惠券 - 状态 - 关闭
// export const closeCoupon = (couponId) => {
//   return requestSync({
//     url: '/system/mallCoupon/offCouponState',
//     method: 'post',
//     data: {
//       couponId
//     }
//   })
// }



// 查询-优惠券模板列表（分页）
export const listCoupon = (params) => {
  return requestSync({
    url: '/mall/coupon/getCouponTemplateList',
    method:'GET',
    params
  })
}
// 删除-优惠券模板（逻辑删除）
export const deleteCoupon = (couponTemplateId) => {
  return requestSync({
    url: '/mall/coupon/deleteCouponTemplate',
    method:'POST',
    params:{
      couponTemplateId:couponTemplateId
    }
  })
}
//开启-优惠券模板
export const openCoupon = (couponTemplateId) => {
  return requestSync({
    url: '/mall/coupon/onCouponTemplate',
    method:'POST',
    params:{
      couponTemplateId:couponTemplateId
    }
  })
}

// 关闭-优惠券模板
export const closeCoupon = (couponTemplateId) => {
  return requestSync({
    url: '/mall/coupon/offCouponTemplate',
    method:'POST',
    params:{
      couponTemplateId:couponTemplateId
    }
  })
}

//新增-优惠券模板
export const addCoupon = (data) => {
  return requestSync({
    url: '/mall/coupon/addCouponTemplate',
    method:'POST',
    data
  })
}

//
// 修改-优惠券模板
export const updateCoupon = (data) => {
  return requestSync({
    url: '/mall/coupon/updateCouponTemplate',
    method:'POST',
    data
  })
}

// 查询-优惠券模板
export const infoCoupon = (couponTemplateId) => {
  return requestSync({
    url: '/mall/coupon/getCouponTemplate',
    method:'GET',
    params:{
      couponTemplateId:couponTemplateId
    }
  })
}

//优惠券模板使用范围指定商品列表
export const getUseGoodsList = () => {
  return requestSync({
    url: '/mall/coupon/getUseGoodsList',
    method:'GET',
  })
}
